# coding=utf-8
import re

# 择一匹配符号（|）的使用
pattern = "aa|bb|cc"
print(re.match(pattern, "aa"))
print(re.match(pattern, "bb"))
print(re.match(pattern, "cc"))
print(re.search(pattern, "where is bb"))

# 匹配0-100之间所有的数字
s = "0"
s = "9"
s = "91"
s = "100"
s = "101"
s = "1000"
pattern = "[1-9]?/d$|100$"
print(re.match(pattern, s))

# 字符集（[]）和择一匹配符(|)的用法，及它们的差异
# 匹配以第1个字母是a或者b，第2个字母是c或者d，如ac、bc、ad、bd
m = re.match('[ab][cd]', 'aceg')
print(m)
# 匹配以ab开头，第3个字母是c或者d，如abc、abd
m = re.match('ab[cd]', 'abcd')
print(m)
# 匹配ab或者cd
m = re.match('ab|cd', 'cd')
print(m)
